package cn.stronglink.asset.module.datacount;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.plugins.Page;

import cn.stronglink.asset.module.datacount.mapper.DataCountMapper;
import cn.stronglink.asset.module.datacount.vo.CabinetCountDetailVo;
import cn.stronglink.asset.module.datacount.vo.DepartmentInfo;
import cn.stronglink.asset.module.datacount.vo.DirectoryEntity;
import cn.stronglink.asset.module.datacount.vo.ItAssetBrandVo;
import cn.stronglink.asset.module.datacount.vo.SearchDetailParam;
import cn.stronglink.asset.module.datacount.vo.SearchParam;
import cn.stronglink.asset.module.report.vo.ExlChartVo;

@Service
@Transactional(rollbackFor=Exception.class)
@SuppressWarnings({"rawtypes","unchecked"})
public class DataCountService {

	@Autowired
	private DataCountMapper dataCountMapper;
	
	public HashMap getAssetTypeCount(SearchParam param) {
		HashMap resultMap=new HashMap();
		List<Long> parentIds=new ArrayList<Long>();
		parentIds.add((long)1);
		List<HashMap> typeList=new ArrayList<HashMap>();
		typeList=getAssetType(typeList,parentIds,param.getTypeIds());
		List<String> typeIds=new ArrayList<String>();
		List<String> labels=new ArrayList<String>();
		List<String> valueIds=new ArrayList<String>();
		//{ title: '楼号', dataIndex: 'buildingName', key: 'buildingName', width: 120, },
		int width=0;
		List<HashMap> columns=new ArrayList<HashMap>();
		HashMap column1=new HashMap();
		column1.put("title", "机房/设备类型");
		column1.put("dataIndex","roomName");
		column1.put("key", "roomName");
		column1.put("width", 120);
		width+=120;
		columns.add(column1);
		valueIds.add("roomName");
		labels.add("机房/设备类型");
		for(HashMap map:typeList){
			HashMap column=new HashMap();
			column.put("title", map.get("name"));
			column.put("dataIndex", map.get("id").toString());
			column.put("key", map.get("id").toString());
			column.put("width", 80);
			columns.add(column);
			width+=80;
			typeIds.add(map.get("id").toString());
			valueIds.add(map.get("id").toString());
			labels.add(map.get("name").toString());
		}
		HashMap columnCon=new HashMap();
		columnCon.put("title", "合计");
		columnCon.put("dataIndex","rowCount");
		columnCon.put("key", "rowCount");
		columnCon.put("width", 80);
		width+=80;
		columns.add(columnCon);
		labels.add("合计");
		valueIds.add("rowCount");
		resultMap.put("width", width);
		resultMap.put("columns", columns);
		resultMap.put("valueIds", valueIds);
		resultMap.put("labels", labels);
		List<HashMap> assetTypeCountList=dataCountMapper.getAssetTypeCount(param);
		List<HashMap> pieData=new ArrayList<HashMap>();
		List<HashMap> roomMapList=new ArrayList<HashMap>();
		List<ExlChartVo> exlChartList = new ArrayList<ExlChartVo>();
		if(assetTypeCountList!=null&&assetTypeCountList.size()>0){
			List<String> roomIds=new ArrayList<String>(); 
			for(HashMap assetTypeCount:assetTypeCountList){
				if(roomIds==null||roomIds.size()==0||!roomIds.contains(assetTypeCount.get("id").toString())){
					roomIds.add(assetTypeCount.get("id").toString());
				}
			}
			
			for(String roomId:roomIds){
				HashMap roomMap=new HashMap();
				roomMap.put("roomId", roomId);
				Integer rowCount=0;
				for(String typeId:typeIds){
					int count=0;
					for(HashMap assetTypeCount:assetTypeCountList){
						if(roomId.equals(assetTypeCount.get("id").toString())){
							roomMap.put("roomName", assetTypeCount.get("name"));
						}
						if(roomId.equals(assetTypeCount.get("id").toString())
								&&assetTypeCount.get("type_id")!=null&&typeId.equals(assetTypeCount.get("type_id").toString())){
							count=assetTypeCount.get("nums")==null?0:Integer.parseInt(assetTypeCount.get("nums").toString());
						}
					}
					roomMap.put(typeId, count);
					rowCount+=count;
				}
				roomMap.put("rowCount", rowCount);
				roomMapList.add(roomMap);
			}
			for(HashMap map:typeList){
				ExlChartVo chartVo = new ExlChartVo();
				HashMap pieMap=new HashMap();
				String typeId=map.get("id").toString();
				pieMap.put("label", map.get("name"));
				chartVo.setColumnKey(map.get("name").toString());
				int count=0;
				for(HashMap roomMap:roomMapList){
					count+=roomMap.get(typeId)==null?0:Integer.parseInt(roomMap.get(typeId).toString());
				}
				pieMap.put("value", count);
				chartVo.setValue(count);
				chartVo.setRowKey("类型台账");
				exlChartList.add(chartVo);
				pieData.add(pieMap);
			}
		}
		resultMap.put("pieData", pieData);
		resultMap.put("dataList", roomMapList);
		resultMap.put("exlChartList", exlChartList);
		return resultMap;
	}

	
	public List<HashMap> getAssetType(List<HashMap> typeList,List<Long> parentIds,List<Long> typeIds){
		List<HashMap> mapList=dataCountMapper.getAssetType(parentIds,typeIds);
		if(mapList!=null&&mapList.size()>0){
			typeList.addAll(mapList);
			parentIds.clear();
			for(HashMap map:mapList){
				parentIds.add(Long.valueOf(map.get("id").toString()));
			}
			getAssetType(typeList,parentIds,typeIds);
		}
		return typeList;
	}

	public HashMap getAssetStatusCount(SearchParam param) {
		HashMap resultMap=new HashMap();
		List<HashMap> statusList=dataCountMapper.getAssetStatus();
		List<String> statusIds=new ArrayList<String>();
		List<String> labels=new ArrayList<String>();
		List<String> valueIds=new ArrayList<String>();
		int width=0;
		List<HashMap> columns=new ArrayList<HashMap>();
		HashMap column1=new HashMap();
		column1.put("title", "机房/设备状态");
		column1.put("dataIndex","roomName");
		column1.put("key", "roomName");
		column1.put("width", 120);
		width+=120;
		columns.add(column1);
		labels.add("机房/设备状态");
		valueIds.add("roomName");
		for(HashMap map:statusList){
			HashMap column=new HashMap();
			column.put("title", map.get("name"));
			column.put("dataIndex", map.get("id").toString());
			column.put("key", map.get("id").toString());
			column.put("width", 80);
			columns.add(column);
			width+=80;
			statusIds.add(map.get("id").toString());
			valueIds.add(map.get("id").toString());
			labels.add(map.get("name").toString());
		}
		HashMap columnCon=new HashMap();
		columnCon.put("title", "合计");
		columnCon.put("dataIndex","rowCount");
		columnCon.put("key", "rowCount");
		columnCon.put("width", 80);
		width+=80;
		columns.add(columnCon);
		labels.add("合计");
		valueIds.add("rowCount");
		resultMap.put("width", width);
		resultMap.put("columns", columns);
		resultMap.put("labels", labels);
		resultMap.put("valueIds", valueIds);
		List<HashMap> assetStatuaCountList=dataCountMapper.getAssetStatusCount(param);
		List<HashMap> roomMapList=new ArrayList<HashMap>();
		List<HashMap> pieData=new ArrayList<HashMap>();
		List<ExlChartVo> exlChartList = new ArrayList<ExlChartVo>();
		if(assetStatuaCountList!=null&&assetStatuaCountList.size()>0){
			List<String> roomIds=new ArrayList<String>(); 
			for(HashMap assetTypeCount:assetStatuaCountList){
				if(roomIds==null||roomIds.size()==0||!roomIds.contains(assetTypeCount.get("id").toString())){
					roomIds.add(assetTypeCount.get("id").toString());
				}
			}
			for(String roomId:roomIds){
				HashMap roomMap=new HashMap();
				roomMap.put("roomId", roomId);
				Integer rowCount=0;
				for(String statusId:statusIds){
					int count=0;
					for(HashMap assetStatusCount:assetStatuaCountList){
						if(roomId.equals(assetStatusCount.get("id").toString())){
							roomMap.put("roomName", assetStatusCount.get("name"));
							if(assetStatusCount.get("assetStatue")!=null&&statusId.equals(assetStatusCount.get("assetStatue").toString())){
								count=assetStatusCount.get("nums")==null?0:Integer.parseInt(assetStatusCount.get("nums").toString());
							}
						}
						
					}
					roomMap.put(statusId, count);
					rowCount+=count;
				}
				roomMap.put("rowCount", rowCount);
				roomMapList.add(roomMap);
			}
			
			for(HashMap map:statusList){
				HashMap pieMap=new HashMap();
				ExlChartVo chartVo = new ExlChartVo();
				String typeId=map.get("id").toString();
				pieMap.put("label", map.get("name"));
				chartVo.setColumnKey(map.get("name").toString());
				int count=0;
				for(HashMap roomMap:roomMapList){
					count+=roomMap.get(typeId)==null?0:Integer.parseInt(roomMap.get(typeId).toString());
				}
				pieMap.put("value", count);
				chartVo.setValue(count);
				chartVo.setRowKey("状态台账");
				exlChartList.add(chartVo);
				pieData.add(pieMap);
			}
		}
		resultMap.put("pieData", pieData);
		resultMap.put("dataList", roomMapList);
		resultMap.put("exlChartList", exlChartList);
		return resultMap;
	}


	public HashMap getAssetBrandCount(SearchParam param) {
		HashMap resultMap=new HashMap();
		List<HashMap> brandList=dataCountMapper.getAssetBrand(param.getBrandIds());
		List<String> brandIds=new ArrayList<String>();
		List<String> labels=new ArrayList<String>();
		List<String> valueIds=new ArrayList<String>();
		int width=0;
		List<HashMap> columns=new ArrayList<HashMap>();
		HashMap column1=new HashMap();
		column1.put("title", "机房/设备品牌");
		column1.put("dataIndex","roomName");
		column1.put("key", "roomName");
		column1.put("width", 120);
		width+=120;
		columns.add(column1);
		valueIds.add("roomName");
		labels.add("机房/设备品牌");
		for(HashMap map:brandList){
			HashMap column=new HashMap();
			column.put("title", map.get("name"));
			column.put("dataIndex", map.get("id").toString());
			column.put("key", map.get("id").toString());
			column.put("width", 80);
			columns.add(column);
			width+=80;
			brandIds.add(map.get("id").toString());
			valueIds.add(map.get("id").toString());
			labels.add(map.get("name").toString());
		}
		HashMap columnCon=new HashMap();
		columnCon.put("title", "合计");
		columnCon.put("dataIndex","rowCount");
		columnCon.put("key", "rowCount");
		columnCon.put("width", 80);
		width+=80;
		columns.add(columnCon);
		valueIds.add("rowCount");
		labels.add("合计");
		resultMap.put("width", width);
		resultMap.put("columns", columns);
		resultMap.put("valueIds", valueIds);
		resultMap.put("labels", labels);
		List<HashMap> assetBrandCountList=dataCountMapper.getAssetBrandCount(param);
		List<HashMap> roomMapList=new ArrayList<HashMap>();
		List<HashMap> pieData=new ArrayList<HashMap>();
		List<ExlChartVo> exlChartList = new ArrayList<ExlChartVo>();
		if(assetBrandCountList!=null&&assetBrandCountList.size()>0){
			List<String> roomIds=new ArrayList<String>(); 
			for(HashMap assetTypeCount:assetBrandCountList){
				if(roomIds==null||roomIds.size()==0||!roomIds.contains(assetTypeCount.get("id").toString())){
					roomIds.add(assetTypeCount.get("id").toString());
				}
			}
			
			for(String roomId:roomIds){
				HashMap roomMap=new HashMap();
				roomMap.put("roomId", roomId);
				Integer rowCount=0;
				for(String brandId:brandIds){
					int count=0;
					for(HashMap assetBrandCount:assetBrandCountList){
						if(roomId.equals(assetBrandCount.get("id").toString())){
							roomMap.put("roomName", assetBrandCount.get("name"));
							if(assetBrandCount.get("brand_id")!=null&&brandId.equals(assetBrandCount.get("brand_id").toString())){
								count=assetBrandCount.get("nums")==null?0:Integer.parseInt(assetBrandCount.get("nums").toString());
							}
						}
						
					}
					roomMap.put(brandId, count);
					rowCount+=count;
				}
				roomMap.put("rowCount", rowCount);
				roomMapList.add(roomMap);
			}
			for(HashMap map:brandList){
				ExlChartVo chartVo = new ExlChartVo();
				HashMap pieMap=new HashMap();
				String typeId=map.get("id").toString();
				pieMap.put("label", map.get("name"));
				chartVo.setColumnKey(map.get("name").toString());
				int count=0;
				for(HashMap roomMap:roomMapList){
					count+=roomMap.get(typeId)==null?0:Integer.parseInt(roomMap.get(typeId).toString());
				}
				pieMap.put("value", count);
				chartVo.setValue(count);
				chartVo.setRowKey("品牌台账");
				exlChartList.add(chartVo);
				pieData.add(pieMap);
			}
		}
		resultMap.put("pieData", pieData);
		resultMap.put("dataList", roomMapList);
		resultMap.put("exlChartList", exlChartList);
		return resultMap;
	}


	public HashMap getAssetDepartCount(SearchParam param) {
		HashMap resultMap=new HashMap();
		List<Long> ids=new ArrayList<Long>();
		if(param.getTypeIds()!=null&&param.getTypeIds().size()>0){
			ids.addAll(param.getTypeIds());
			ids=getParentIds(ids,ids);
		}
		List<HashMap> departList=dataCountMapper.getAssetDepart(ids);
		List<HashMap> assetDepartCountList=dataCountMapper.getAssetDepartCount(param);
		List<String> departIds=new ArrayList<String>();
		List<String> labels=new ArrayList<String>();
		List<String> valueIds=new ArrayList<String>();
		int width=0;
		List<HashMap> columns=new ArrayList<HashMap>();
		HashMap column1=new HashMap();
		column1.put("title", "机房/领用部门");
		column1.put("dataIndex","roomName");
		column1.put("key", "roomName");
		column1.put("width", 120);
		columns.add(column1);
		valueIds.add("roomName");
		labels.add("机房/领用部门");
		width+=120;
		for(HashMap map:departList){
			HashMap column=new HashMap();
			column.put("title", map.get("name"));
			column.put("dataIndex", map.get("id").toString());
			column.put("key", map.get("id").toString());
			column.put("width", 100);
			columns.add(column);
			width+=100;
			departIds.add(map.get("id").toString());
			valueIds.add(map.get("id").toString());
			labels.add(map.get("name").toString());
		}
		for(HashMap depart:assetDepartCountList){
			if(depart.get("branch_id")!=null
					&&(departIds==null||departIds.size()==0||!departIds.contains(depart.get("branch_id").toString()))){
				departIds.add(depart.get("branch_id").toString());
				HashMap column=new HashMap();
				column.put("title", depart.get("departName"));
				column.put("dataIndex", depart.get("branch_id").toString());
				column.put("key", depart.get("branch_id").toString());
				column.put("width", 100);
				columns.add(column);
				width+=100;
				HashMap map=new HashMap();
				map.put("id", depart.get("branch_id").toString());
				map.put("name", depart.get("departName").toString());
				departList.add(map);
				valueIds.add(depart.get("branch_id").toString());
				labels.add(depart.get("departName").toString());
			}
		}
		HashMap columnCon=new HashMap();
		columnCon.put("title", "合计");
		columnCon.put("dataIndex","rowCount");
		columnCon.put("key", "rowCount");
		columnCon.put("width", 100);
		width+=100;
		columns.add(columnCon);
		valueIds.add("rowCount");
		labels.add("合计");
		resultMap.put("width", width);
		resultMap.put("columns", columns);
		resultMap.put("valueIds", valueIds);
		resultMap.put("labels", labels);
		
		List<HashMap> roomMapList=new ArrayList<HashMap>();
		List<HashMap> pieData=new ArrayList<HashMap>();
		List<ExlChartVo> exlChartList = new ArrayList<ExlChartVo>();
		if(assetDepartCountList!=null&&assetDepartCountList.size()>0){
			List<String> roomIds=new ArrayList<String>(); 
			for(HashMap assetDepartCount:assetDepartCountList){
				if(roomIds==null||roomIds.size()==0||!roomIds.contains(assetDepartCount.get("id").toString())){
					roomIds.add(assetDepartCount.get("id").toString());
				}
			}
			
			for(String roomId:roomIds){
				HashMap roomMap=new HashMap();
				roomMap.put("roomId", roomId);
				Integer rowCount=0;
				for(String departId:departIds){
					int count=0;
					for(HashMap assetDepartCount:assetDepartCountList){
						if(roomId.equals(assetDepartCount.get("id").toString())){
							roomMap.put("roomName", assetDepartCount.get("name"));
							if(assetDepartCount.get("branch_id")!=null&&departId.equals(assetDepartCount.get("branch_id").toString())){
								count=assetDepartCount.get("nums")==null?0:Integer.parseInt(assetDepartCount.get("nums").toString());
							}
						}
						
					}
					roomMap.put(departId, count);
					rowCount+=count;
				}
				roomMap.put("rowCount", rowCount);
				roomMapList.add(roomMap);
			}
			for(HashMap map:departList){
				ExlChartVo chartVo = new ExlChartVo();
				HashMap pieMap=new HashMap();
				String typeId=map.get("id").toString();
				pieMap.put("label", map.get("name"));
				chartVo.setColumnKey(map.get("name").toString());
				int count=0;
				for(HashMap roomMap:roomMapList){
					count+=roomMap.get(typeId)==null?0:Integer.parseInt(roomMap.get(typeId).toString());
				}
				pieMap.put("value", count);
				chartVo.setValue(count);
				chartVo.setRowKey("领用部门台账");
				exlChartList.add(chartVo);
				pieData.add(pieMap);
			}
		}
		resultMap.put("pieData", pieData);
		resultMap.put("dataList", roomMapList);
		resultMap.put("exlChartList", exlChartList);
		return resultMap;
	}


	public List<DirectoryEntity> getRoom() {
		return dataCountMapper.getRoom();
	}


	public List<DirectoryEntity> getAssetType() {
		List<DirectoryEntity> directoryEntityList=new ArrayList<DirectoryEntity>();
		List<Long> parentIds=new ArrayList<Long>();
		parentIds.add((long)1);
		List<HashMap> typeList=new ArrayList<HashMap>();
		List<Long> typeIds=new ArrayList<Long>();
		typeList=getAssetType(typeList,parentIds,typeIds);
		if(typeList!=null&&typeList.size()>0){
			for(HashMap map:typeList){
				DirectoryEntity directoryEntity=new DirectoryEntity();
				directoryEntity.setId(map.get("id").toString());
				directoryEntity.setName(map.get("name").toString());
				directoryEntityList.add(directoryEntity);
			}
		}
		return directoryEntityList;
	}


	public List<DirectoryEntity> getAssetBrand() {
		List<DirectoryEntity> brandList=dataCountMapper.getAssetBrand1();

		return brandList;
	}


	public List<DepartmentInfo> getDepartments() {
		List<DepartmentInfo> parentList=dataCountMapper.getDepartmentInfoList(Long.valueOf("-1"));
		if(parentList!=null&&parentList.size()>0){
			for(DepartmentInfo vo:parentList){
				getChildren(vo);
			}
		}
		return parentList;
	}
	
	
	public void getChildren(DepartmentInfo vo){
		List<DepartmentInfo> voList=dataCountMapper.getDepartmentChildrenInfoList(vo.getId());
		if(voList!=null&&voList.size()>0){
			for(DepartmentInfo child:voList){
				getChildren(child);
			}
			vo.setChildren(voList);
		}
	}
	
	public List<Long> getParentIds(List<Long> ids,List<Long> childrenIds){
		List<Long> parentIds=dataCountMapper.getDepartParentIds(childrenIds);
		if(parentIds!=null&&parentIds.size()>0){
			ids.addAll(parentIds);
			getParentIds(ids,parentIds);
		}
		return ids;
	}


	public Page<ItAssetBrandVo> queryBrandDataDetail(Page<ItAssetBrandVo> page,SearchDetailParam param) {
		// TODO Auto-generated method stub
		//return dataCountMapper.queryBrandDataDetail(param);
		page.setRecords(dataCountMapper.queryBrandDataDetail(page,param));
		return page;
	}


	public Page<ItAssetBrandVo> queryDepartDataDetail(Page<ItAssetBrandVo> page, SearchDetailParam param) {
		page.setRecords(dataCountMapper.queryDepartDataDetail(page,param));
		return page;
	}


	public Page<ItAssetBrandVo> queryStatusDataDetail(Page<ItAssetBrandVo> page, SearchDetailParam param) {
		page.setRecords(dataCountMapper.queryStatusDataDetail(page,param));
		return page;
	}


	public Page<ItAssetBrandVo> queryTypeDataDetail(Page<ItAssetBrandVo> page, SearchDetailParam param) {
		page.setRecords(dataCountMapper.queryTypeDataDetail(page,param));
		return page;
	}


	public HashMap serviceLifeCount(SearchParam param) {
			HashMap resultMap=new HashMap();			
			List<HashMap> serviceLifeList=dataCountMapper.getServiceLife();//[{"name":1,"id":1},{"name":2,"id":2},{"name":7,"id":7}]
			List<HashMap> serviceLifeCountList=dataCountMapper.getServiceLifeCount(param);
			List<String> departIds=new ArrayList<String>();
			List<String> labels=new ArrayList<String>();
			List<String> valueIds=new ArrayList<String>();
			int width=0;
			List<HashMap> columns=new ArrayList<HashMap>();
			HashMap column1=new HashMap();
			column1.put("title", "机房/使用年限");
			column1.put("dataIndex","roomName");
			column1.put("key", "roomName");
			column1.put("width", 120);
			columns.add(column1);
			valueIds.add("roomName");
			labels.add("机房/使用年限");
			width+=120;
			
			for(HashMap map:serviceLifeList){
				HashMap column=new HashMap();
				column.put("title", map.get("name"));
				column.put("dataIndex", map.get("id").toString());
				column.put("key", map.get("id").toString());
				column.put("width", 100);
				columns.add(column);
				width+=100;
				departIds.add(map.get("id").toString());
				valueIds.add(map.get("id").toString());
				labels.add(map.get("name").toString());
			}
			HashMap columnCon=new HashMap();
			columnCon.put("title", "合计");
			columnCon.put("dataIndex","rowCount");
			columnCon.put("key", "rowCount");
			columnCon.put("width", 100);
			width+=100;
			columns.add(columnCon);
			labels.add("合计");
			valueIds.add("rowCount");
			resultMap.put("width", width);
			resultMap.put("columns", columns);
			resultMap.put("labels", labels);
			resultMap.put("valueIds", valueIds);
			List<HashMap> roomMapList=new ArrayList<HashMap>();
			List<HashMap> pieData=new ArrayList<HashMap>();
			List<ExlChartVo> exlChartList = new ArrayList<ExlChartVo>();
			if(serviceLifeCountList!=null&&serviceLifeCountList.size()>0){
				List<String> roomIds=new ArrayList<String>(); 
				for(HashMap serviceLifeCount:serviceLifeCountList){
					if(roomIds==null||roomIds.size()==0||!roomIds.contains(serviceLifeCount.get("id").toString())){
						roomIds.add(serviceLifeCount.get("id").toString());
					}
				}
				
				for(String roomId:roomIds){
					HashMap roomMap=new HashMap();
					roomMap.put("roomId", roomId);
					Integer rowCount=0;
					for(String statusId:departIds){
						int count=0;
						for(HashMap assetYearCount:serviceLifeCountList){
							if(roomId.equals(assetYearCount.get("id").toString())){
								roomMap.put("roomName", assetYearCount.get("name"));
								if(assetYearCount.get("year")!=null&&statusId.equals(assetYearCount.get("year").toString())){
									count=assetYearCount.get("nums")==null?0:Integer.parseInt(assetYearCount.get("nums").toString());
								}
							}
							
						}
						roomMap.put(statusId, count);
						rowCount+=count;
					}
					roomMap.put("rowCount", rowCount);
					roomMapList.add(roomMap);
				}
				
				for(HashMap map:serviceLifeList){
					ExlChartVo chartVo = new ExlChartVo();
					HashMap pieMap=new HashMap();
					String typeId=map.get("id").toString();
					pieMap.put("label", map.get("name"));
					chartVo.setColumnKey(map.get("name").toString());
					int count=0;
					for(HashMap roomMap:roomMapList){
						count+=roomMap.get(typeId)==null?0:Integer.parseInt(roomMap.get(typeId).toString());
					}
					pieMap.put("value", count);
					chartVo.setValue(count);
					chartVo.setRowKey("使用年限台账");
					exlChartList.add(chartVo);
					pieData.add(pieMap);
				}
			}
			resultMap.put("pieData", pieData);
			resultMap.put("dataList", roomMapList);
			resultMap.put("exlChartList", exlChartList);
			return resultMap;
	}
	
	public HashMap CabinetCount(SearchParam param) {
		HashMap resultMap=new HashMap();	
		List<HashMap> CabinetCount=dataCountMapper.getCabinetCount(param);
		Integer oneCount = 0;
		Integer twoCount = 0;
		Integer threeCount = 0;
		if (CabinetCount!=null && CabinetCount.size()>0) {
			for (HashMap cab : CabinetCount) {
				oneCount+=cab.get("oneStage")==null?0:Integer.parseInt(cab.get("oneStage").toString());
				twoCount+=cab.get("twoStage")==null?0:Integer.parseInt(cab.get("twoStage").toString());
				threeCount+=cab.get("threeStage")==null?0:Integer.parseInt(cab.get("threeStage").toString());
			}
		}
		List<ExlChartVo> exlChartList = new ArrayList<ExlChartVo>();
		List<HashMap> pieData=new ArrayList<HashMap>();
		for (int i = 1; i < 4; i++) {
			ExlChartVo chartVo = new ExlChartVo();
			HashMap pieMap=new HashMap();
			if (i==1) {
				chartVo.setColumnKey("0%-40%");
				chartVo.setValue(oneCount);
				pieMap.put("label","0%-40%");
				pieMap.put("value", oneCount);
			}
			if (i==2) {
				chartVo.setColumnKey("40%-60%");
				chartVo.setValue(twoCount);
				pieMap.put("label","40%-60%");
				pieMap.put("value", twoCount);
			}
			if (i==3) {
				chartVo.setColumnKey("60%-100%");
				chartVo.setValue(threeCount);
				pieMap.put("label","60%-100%");
				pieMap.put("value", threeCount);
			}
			chartVo.setRowKey("机柜使用率台账");
			exlChartList.add(chartVo);
			pieData.add(pieMap);
		}
		resultMap.put("pieData", pieData);
		resultMap.put("dataList", CabinetCount);
		resultMap.put("exlChartList", exlChartList);
		return resultMap;
	}


	public Page<ItAssetBrandVo> queryServiceLifeDetail(Page<ItAssetBrandVo> page, SearchDetailParam param) {
		page.setRecords(dataCountMapper.queryServiceLifeDetail(page,param));
		return page;
	}


	public Page<CabinetCountDetailVo> queryCabinetCountDetail(Page<CabinetCountDetailVo> page,
			SearchDetailParam param) {
		page.setRecords(dataCountMapper.queryCabinetCountDetail(page,param));
		return page;
	}


	
}